package shell_sort

import(
	//"log"
)

//ShellSort 希尔排序
func ShellSort(nums []int) []int {
	ln := len(nums)
	if ln < 2 {
		return nums
	}
	for gap := ln/2; gap > 0; gap /= 2 {
		for n := 0; n < ln; n++ {
			for m := n+gap; m < ln; m += gap {
				for k := m; k > n; k -= gap {
					if nums[k-gap] > nums[k] {
						nums[k-gap], nums[k] = nums[k], nums[k-gap]
					}
				}
			}
		}
	}
	return nums
}